---@class GT.camera
---@field camera Camera
GT.camera = class()

---@class camera_data
---@field camera Camera

function GT.camera:ctor(data)
    self.camera = data.camera
end

---@param camera Camera
---@return GT.camera
function GT.camera.obj(camera)
    return new(GT.camera, { camera = camera })
end

--- 创建镜头
---@param focus_point FVector3 点
---@param dis Float 焦距
---@param focus_y Float 焦点高度
---@param yaw Float yaw
---@param pitch Float pitch
---@param fov Float fov
---@return GT.camera
function GT.camera.add_camera_conf(focus_point, dis, focus_y, yaw, pitch, fov)
    return GT.camera.obj(game_api.add_camera_conf(focus_point, Fix32(dis), Fix32(focus_y), Fix32(yaw), Fix32(pitch),
        Fix32(fov)))
end

--- 应用镜头配置
---@param role Role 玩家
---@param duration Float 过渡时间
---@param slope_mode Int8 镜头移动类型
function GT.camera:apply_camera_conf(role, duration, slope_mode)
    game_api.apply_camera_conf(role, self.camera, duration, slope_mode)
    return GT.camera
end

--- 线性移动镜头(时间)
---@param role GT.player 玩家
---@param point GT.point 点
---@param duration number 持续时间
---@param acc Int32 加速度
function GT.camera.camera_linear_move_duration(role, point, duration, acc)
    game_api.camera_linear_move_duration(role.player, point.point, Fix32(duration), acc)
end

--- 线性移动镜头(初速度)
---@param role Role 玩家
---@param point FVector3 点
---@param speed Fixed 初速度
---@param acc Int32 加速度
function GT.camera.camera_linear_move_speed(role, point, speed, acc)
    game_api.camera_linear_move_speed(role, point, speed, acc)
end

--- 让镜头看向某点（镜头位置不变）
---@param role Role 玩家
---@param point FVector3 点
---@param move_time Fixed 时间
function GT.camera.camera_look_at(role, point, move_time)
    game_api.camera_look_at(role, point, move_time)
    return GT.camera
end

--- 设置镜头参数roll
---@param role Role 玩家
---@param roll Fixed 滚动角
---@param move_time Fixed 时间
function GT.camera.camera_set_param_roll(role, roll, move_time)
    game_api.camera_set_param_roll(role, roll, move_time)
    return GT.camera
end

--- 设置镜头参数pitch
---@param role Role 玩家
---@param pitch Fixed 俯仰角
---@param move_time Fixed 时间
function GT.camera.camera_set_param_pitch(role, pitch, move_time)
    game_api.camera_set_param_pitch(role, pitch, move_time)
    return GT.camera
end

--- 设置镜头参数yaw
---@param role Role 玩家
---@param yaw Fixed 导航角
---@param move_time Fixed 时间
function GT.camera.camera_set_param_yaw(role, yaw, move_time)
    game_api.camera_set_param_yaw(role, yaw, move_time)
    return GT.camera
end

--- 设置镜头角度参数
---@param role Role 玩家
---@param rotate_type CameraRotate 角度类型
---@param angle Fixed 角度值
---@param move_time Fixed 时间
function GT.camera.camera_set_param_rotate(role, rotate_type, angle, move_time)
    game_api.camera_set_param_rotate(role, rotate_type, angle, move_time)
    return GT.camera
end

--- 设置镜头参数distance
---@param role Role 玩家
---@param distance Fixed 焦点距离
---@param move_time Fixed 时间
function GT.camera.camera_set_param_distance(role, distance, move_time)
    game_api.camera_set_param_distance(role, distance, move_time)
    return GT.camera
end

--- 旋转镜头俯仰角（角度，时间）
---@param role Role 玩家
---@param angle Fixed 角度
---@param duration Fixed 时间
function GT.camera.camera_rotate_pitch_angle_duration(role, angle, duration)
    game_api.camera_rotate_pitch_angle_duration(role, angle, duration)
    return GT.camera
end

--- 旋转镜头俯仰角（角速度，时间）
---@param role Role 玩家
---@param angle_speed Fixed 角速度
---@param duration Fixed 时间
function GT.camera.camera_rotate_pitch_speed_duration(role, angle_speed, duration)
    game_api.camera_rotate_pitch_speed_duration(role, angle_speed, duration)
    return GT.camera
end

--- 旋转镜头俯仰角（角速度，角度）
---@param role Role 玩家
---@param angle_speed Fixed 角速度
---@param angle Fixed 角度
function GT.camera.camera_rotate_pitch_speed_angle(role, angle_speed, angle)
    game_api.camera_rotate_pitch_speed_angle(role, angle_speed, angle)
    return GT.camera
end

--- 旋转镜头导航角（角度，时间）
---@param role Role 玩家
---@param angle Fixed 角度
---@param duration Fixed 时间
function GT.camera.camera_rotate_yaw_angle_duration(role, angle, duration)
    game_api.camera_rotate_yaw_angle_duration(role, angle, duration)
    return GT.camera
end

--- 旋转镜头导航角（角速度，时间）
---@param role Role 玩家
---@param angle_speed Fixed 角速度
---@param duration Fixed 时间
function GT.camera.camera_rotate_yaw_speed_duration(role, angle_speed, duration)
    game_api.camera_rotate_yaw_speed_duration(role, angle_speed, duration)
    return GT.camera
end

--- 旋转镜头导航角（角速度，角度）
---@param role Role 玩家
---@param angle_speed Fixed 角速度
---@param angle Fixed 角度
function GT.camera.camera_rotate_yaw_speed_angle(role, angle_speed, angle)
    game_api.camera_rotate_yaw_speed_angle(role, angle_speed, angle)
    return GT.camera
end

--- 旋转镜头滚角（角度，时间）
---@param role Role 玩家
---@param angle Fixed 角度
---@param duration Fixed 时间
function GT.camera.camera_rotate_roll_angle_duration(role, angle, duration)
    game_api.camera_rotate_roll_angle_duration(role, angle, duration)
    return GT.camera
end

--- 旋转镜头滚角（角速度，时间）
---@param role Role 玩家
---@param angle_speed Fixed 角速度
---@param duration Fixed 时间
function GT.camera.camera_rotate_roll_speed_duration(role, angle_speed, duration)
    game_api.camera_rotate_roll_speed_duration(role, angle_speed, duration)
    return GT.camera
end

--- 旋转镜头滚角（角速度，角度）
---@param role Role 玩家
---@param angle_speed Fixed 角速度
---@param angle Fixed 角度
function GT.camera.camera_rotate_roll_speed_angle(role, angle_speed, angle)
    game_api.camera_rotate_roll_speed_angle(role, angle_speed, angle)
    return GT.camera
end

--- 镜头摇晃xy
---@param role Role 玩家
---@param amplitude Fixed 摇晃幅度
---@param speed Fixed 摇晃速率
---@param duration Fixed 持续时间
---@param t Int32 摇晃方式
function GT.camera.camera_shake_xy(role, amplitude, speed, duration, t)
    game_api.camera_shake_xy(role, amplitude, speed, duration, t)
    return GT.camera
end

--- 镜头摇晃z
---@param role Role 玩家
---@param amplitude Fixed 摇晃幅度
---@param speed Fixed 摇晃速率
---@param duration Fixed 持续时间
function GT.camera.camera_shake_z(role, amplitude, speed, duration)
    game_api.camera_shake_z(role, amplitude, speed, duration)
    return GT.camera
end

--- 镜头摇晃xy
---@param role Role 玩家
---@param amplitude Fixed 摇晃幅度
---@param speed Fixed 摇晃速率
---@param duration Fixed 持续时间
---@param shake_mode Int32 摇晃方式
function GT.camera.camera_shake(role, amplitude, speed, duration, shake_mode)
    game_api.camera_shake(role, amplitude, speed, duration, shake_mode)
    return GT.camera
end

--- 镜头带衰减震动
---@param role Role 玩家
---@param amplitude Fixed 震动幅度
---@param decay Fixed 衰减速率
---@param frequency Fixed 频率
---@param duration Fixed 持续时间
---@param shake_type Int32 震动方式
function GT.camera.camera_shake_with_decay(role, amplitude, decay, frequency, duration, shake_type)
    game_api.camera_shake_with_decay(role, amplitude, decay, frequency, duration, shake_type)
    return GT.camera
end

--- 镜头限制移动区域
---@param role Role 玩家
---@param area Area 限制区域
function GT.camera.camera_limit_area(role, area)
    game_api.camera_limit_area(role, area)
    return GT.camera
end

--- 镜头限制移动区域
---@param role Role 玩家
function GT.camera.camera_limit_area_close(role)
    game_api.camera_limit_area_close(role)
    return GT.camera
end

--- 镜头跟随某个单位
---@param role Role 玩家
---@param unit Unit 跟随单位
---@param offset_x Float 偏移距离x
---@param offset_y Float 偏移距离y
---@param offset_height Float 偏移高度
function GT.camera.camera_set_follow_unit(role, unit, offset_x, offset_y, offset_height)
    game_api.camera_set_follow_unit(role, unit, offset_x, offset_y, offset_height)
    return GT.camera
end

--- 镜头tps跟随某个单位
---@param role Role 玩家
---@param unit Unit 跟随单位
---@param sensitive Float 灵敏度
---@param pitch Float 俯仰角
---@param yaw Float 偏航角
---@param offset_x Float 偏移距离x
---@param offset_y Float 偏移距离y
---@param offset_z Float 偏移高度
---@param distance Float 摄像机距离
function GT.camera.camera_set_tps_follow_unit(role, unit, sensitive, pitch, yaw, offset_x, offset_y, offset_z, distance)
    game_api.camera_set_tps_follow_unit(role, unit, sensitive, pitch, yaw, offset_x, offset_y, offset_z, distance)
    return GT.camera
end

--- 取消镜头tps跟随单位
---@param role Role 玩家
function GT.camera.camera_cancel_tps_follow_unit(role)
    game_api.camera_cancel_tps_follow_unit(role)
    return GT.camera
end

--- 将玩家相机解除绑定
---@param role Role 玩家
function GT.camera.camera_cancel_follow_unit(role)
    game_api.camera_cancel_follow_unit(role)
    return GT.camera
end

--- 本地镜头在跟随状态
---@return Bool
function GT.camera.camera_is_following_target()
    return game_api.camera_is_following_target()
end

--- 设置玩家镜头焦点高度
---@param role Role 玩家
---@param y Fixed 高度
---@param move_time Fixed 时间
function GT.camera.camera_set_focus_y(role, y, move_time)
    game_api.camera_set_focus_y(role, y, move_time)
    return GT.camera
end

--- 设置玩家相机允许移动
---@param role Role 玩家
function GT.camera.camera_set_move_enable(role)
    game_api.camera_set_move_enable(role)
    return GT.camera
end

--- 设置玩家相机禁止移动
---@param role Role 玩家
function GT.camera.camera_set_move_not_enable(role)
    game_api.camera_set_move_not_enable(role)
    return GT.camera
end

--- 玩家镜头是否正在播放动画
---@param role Role 玩家
---@return Bool
function GT.camera.is_cameraIS_playing_timeline(role)
    game_api.is_cameraIS_playing_timeline(role)
    return GT.camera
end

--- 播放镜头动画
---@param role Role 玩家
---@param camline_id CamlineID 镜头TimelineID
function GT.camera.play_camera_timeline(role, camline_id)
    game_api.play_camera_timeline(role, camline_id)
    return GT.camera
end

--- 停止播放镜头动画
---@param role Role 玩家
function GT.camera.stop_camera_timeline(role)
    game_api.stop_camera_timeline(role)
    return GT.camera
end

--- 本地玩家摄像机朝向
---@return Point
function GT.camera.get_local_player_camera_direction()
    return game_api.get_local_player_camera_direction()
end

--- 本地玩家摄像机中心射线检测
---@return Point
function GT.camera.get_local_player_camera_center_raycast()
    return game_api.get_local_player_camera_center_raycast()
end

--- 镜头是否存在
---@param camera Camera 镜头
---@return Bool
function GT.camera.camera_is_exist(camera)
    return game_api.camera_is_exist(camera)
end
